package com.crscd.ai.config;

import com.alibaba.cloud.ai.dashscope.api.DashScopeApi;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatModel;
import com.alibaba.cloud.ai.dashscope.chat.DashScopeChatOptions;
import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.ai.chat.prompt.ChatOptions;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created with IntelliJ IDEA.
 *
 * @description: 多个模型共存
 * @author: liuziyang
 * @since: 9/30/25 10:13 AM
 * @modifiedBy:
 * @version: 1.0
 */
@Configuration
public class SaaLLMConfig {
  private static final String DEEPSEEK_MODEL = "deepseek-v3.1";
  private static final String QWEN_MODEL = "qwen3-max";

  @Bean("deepseek")
  public ChatModel deepSeek() {
    return DashScopeChatModel.builder()
        .dashScopeApi(DashScopeApi.builder().apiKey("sk-58f28078ed944be89955f28e1e3b1137").build())
        .defaultOptions(DashScopeChatOptions.builder().withModel(DEEPSEEK_MODEL).build())
        .build();
  }

  @Bean("qwen")
  public ChatModel qwen() {
    return DashScopeChatModel.builder()
        .dashScopeApi(DashScopeApi.builder().apiKey("sk-58f28078ed944be89955f28e1e3b1137").build())
        .defaultOptions(DashScopeChatOptions.builder().withModel(QWEN_MODEL).build())
        .build();
  }

  @Bean("deepseekChatClient")
  public ChatClient deepseekChatClient() {
    return ChatClient.builder(deepSeek())
        .defaultOptions(ChatOptions.builder().model(DEEPSEEK_MODEL).build())
        .build();
  }

  @Bean("qwenChatClient")
  public ChatClient qwenChatClient() {
    return ChatClient.builder(qwen())
        .defaultOptions(ChatOptions.builder().model(QWEN_MODEL).build())
        .build();
  }
}
